---
title: LangDB Embedder
sidebarTitle: LangDB
---

The `LangDBEmbedder` class is used to embed text data into vectors using the LangDB API. This embedder provides high-quality embeddings that can be used with various vector databases for semantic search and similarity matching.

## Usage

```python langdb_embedder.py
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.embedder.langdb import LangDBEmbedder
from agno.vectordb.pgvector import PgVector

# Get embeddings for a text
embeddings = LangDBEmbedder().get_embedding("Embed me")

# Print the embeddings and their dimensions
print(f"Embeddings: {embeddings[:5]}")
print(f"Dimensions: {len(embeddings)}")

# Example usage with a knowledge base:
knowledge = Knowledge(
    vector_db=PgVector(
        db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
        table_name="langdb_embeddings",
        embedder=LangDBEmbedder(),
    ),
    max_results=2,
)
```

## Params

| Parameter         | Type                       | Default | Description                                                      |
| ----------------- | -------------------------- | ------- | ---------------------------------------------------------------- |
| `api_key`         | `str`                      | -       | The API key used for authenticating requests to LangDB             |
| `project_id`      | `str`                      | -       | The project ID associated with your LangDB account                |
| `model`           | `str`                      | -       | The name of the model used for generating embeddings              |
| `dimensions`      | `int`                      | -       | The dimensionality of the embeddings generated by the model       |
| `base_url`        | `str`                      | -       | The base URL for the LangDB API endpoint                          |
| `request_params`  | `Optional[Dict[str, Any]]` | -       | Additional parameters to include in the API request                |
| `client_params`   | `Optional[Dict[str, Any]]` | -       | Additional parameters for configuring the API client               |

## Environment Variables

```bash
export LANGDB_API_KEY=xxx
export LANGDB_PROJECT_ID=xxx
```

## Developer Resources
- View [Cookbook](https://github.com/agno-agi/agno/tree/main/cookbook/knowledge/embedders/langdb_embedder.py)
